<?php if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
<!doctype html>
<html>
<head>
<meta charset="<?php $this->options->charset(); ?>">
<meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1">
<meta name="renderer" content="webkit">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta http-equiv="Cache-Control" content="no-transform"/>
<meta http-equiv="Cache-Control" content="no-siteapp"/>
<meta name="baidu-site-verification" content="tJZAVeGyJt" />
<meta name="keywords" content="<?php $this->keywords() ?>" />
<?php $this->header('keywords=&generator=&template=&pingback=&xmlrpc=&wlw=&commentReply=&rss1=&rss2=&atom='); ?>
<!--[if lt IE 9]>
	<script src="//cdn.bootcss.com/html5shiv/r29/html5.min.js"></script>
	<script src="//cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
<link rel="shortcut icon" href="<?php if($this->options->favicon): $this->options->favicon(); else: $this->options->themeUrl('images/touxiang.png');endif; ?>">
<link rel="stylesheet" href="<?php $this->options->themeUrl('style.css?v=170120'); ?>">
<title><?php $this->archiveTitle(array(
	'category'  =>  _t(' %s '),
	'search'    =>  _t(' %s '),
	'tag'       =>  _t(' %s '),
	'author'    =>  _t(' %s ')
	), '', ' - '); ?><?php $this->options->title(); ?></title>
<link rel="stylesheet" href="<?php $this->options->themeUrl('prism.css'); ?>">
<script src="<?php $this->options->themeUrl('prism.js'); ?>"></script>

</head>
<body>
<!--[if lt IE 9]>
	<div class="browsehappy" role="dialog">你正在使用一个过时的浏览器，为了正常的访问, 请<a href="https://browsehappy.com/" target="_blank">升级你的浏览器</a>以查看此页面。</div>
<![endif]-->
<div class="container">
    <div class="left-col" style="background-image: url(<?php if($this->options->iosicon): $this->options->iosicon(); else: $this->options->themeUrl('images/left-bg.jpg');endif; ?>);">
        <header id="header">
            <div class="profilepic"><a href="/" style="background-image: url(<?php if($this->options->touxiang): $this->options->touxiang(); else: $this->options->themeUrl('images/touxiang.png');endif; ?>);"></a></div>
            <h1><a href="/"><?php $this->options->title() ?></a></h1>
            <p class="subtitle"><?php $this->options->slogan(); ?></p>
            <nav id="main-nav">
                <ul>
                   <li><a href="<?php $this->options->siteUrl(); ?>"><i class="iconfont icon-home"></i>首页</a></li>
                   <li><a href="<?php $this->options->siteUrl(); ?>about.html"><i class="iconfont icon-aboutus"></i>关于</a></li>
                   <li><a href="<?php $this->options->siteUrl(); ?>archives.html"><i class="iconfont icon-collect"></i>归档</a></li>
                   <li><a href="<?php $this->options->siteUrl(); ?>links.html"><i class="iconfont icon-links"></i>友链</a></li>
                </ul>
            </nav>
            <nav id="sub-nav">
                <div class="social">
                    <?php if ($this->options->socialgithub): ?>
                    <a class="social github" target="blank" href="<?php $this->options->socialgithub(); ?>"><i class="iconfont icon-github"></i></a>
                    <?php endif; ?>
                    <?php if ($this->options->socialgoogle): ?>
                    <a class="social google-plus" target="blank" href="<?php $this->options->socialgoogle(); ?>"><i class="iconfont icon-google"></i></a>
                    <?php endif; ?>
                    <?php if ($this->options->socialtwitter): ?>
                    <a class="social twitter" target="blank" href="<?php $this->options->socialtwitter(); ?>"><i class="iconfont icon-twitter"></i></a>
                    <?php endif; ?>
                    <?php if ($this->options->socialwechat): ?>
                    <a id="wechat-toggle" class="social wechat" href="javascript:"><i class="iconfont icon-wechat"></i></a>
                    <?php endif; ?>
                    <?php if ($this->options->socialqq): ?>
                    <a class="social qq" target="blank" href="tencent://message/?uin=<?php $this->options->socialqq(); ?>&Site=junichi&Menu=yes"><i class="iconfont icon-qq"></i></a>
                    <?php endif; ?>
                    <?php if ($this->options->socialweibo): ?>
                    <a class="social weibo" target="blank" href="<?php $this->options->socialweibo(); ?>"><i class="iconfont icon-weibo"></i></a>
                    <?php endif; ?>
                    <?php if ($this->options->socialmusic): ?>
                    
                    <a class="social music" target="blank" href="javascript:;" id="musicBtn"><i class="iconfont icon-music" id="musicico"></i></a>

<style type="text/css">
                        .icon-music{
                            display: inline-block;
                        }
                        @media screen and (max-width: 640px){
                            #header a:hover{
                                color: #efefef!important;
                            }
                        }
                        @keyframes musicplay
                        {
                            from {transform: rotate(0deg);}
                            to {transform: rotate(360deg);}
                        }
                        @-moz-keyframes musicplay /* Firefox */
                        {
                            from {transform: rotate(0deg);}
                            to {transform: rotate(360deg);}
                        }

                        @-webkit-keyframes musicplay /* Safari 和 Chrome */
                        {
                            from {transform: rotate(0deg);}
                            to {transform: rotate(360deg);}
                        }

                        @-o-keyframes musicplay /* Opera */
                        {
                            from {transform: rotate(0deg);}
                            to {transform: rotate(360deg);}
                        }
                    </style>
                    <script type="text/javascript">
                        var musicSrc ="<?php
    function netease_AESECB($API) {
        $KEY='7246674226682325323F5E6544673A51';
        $body=json_encode($API['body']);
        if (function_exists('openssl_encrypt')) {
            $body=openssl_encrypt($body, 'aes-128-ecb', pack('H*', $KEY));
        } else {
            $PAD=16-(strlen($body)%16);
            $body=base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_128, hex2bin($KEY), $body.str_repeat(chr($PAD), $PAD), MCRYPT_MODE_ECB));
        }
        $body=strtoupper(bin2hex(base64_decode($body)));

        $API['body']=array(
            'eparams'=>$body,
        );
        return $API;
    }
function curl($API) {
    $API=netease_AESECB($API);
    $BASE = array(
                'referer'   => 'https://music.163.com/',
                'cookie'    => 'os=linux; appver=1.0.0.1026; osver=Ubuntu%2016.10; MUSIC_U=78d411095f4b022667bc8ec49e9a44cca088df057d987f5feaf066d37458e41c4a7d9447977352cf27ea9fee03f6ec4441049cea1c6bb9b6; __remember_me=true',
                'useragent' => 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36',
            );
    $curl=curl_init();
        if ($API['method']=='POST') {
            if (is_array($API['body'])) {
                $API['body']=http_build_query($API['body']);
            }
            curl_setopt($curl, CURLOPT_POST, 1);
            curl_setopt($curl, CURLOPT_POSTFIELDS, $API['body']);
        } elseif ($API['method']=='GET') {
            if (isset($API['body'])) {
                $API['url']=$API['url'].'?'.http_build_query($API['body']);
            }
        }
        curl_setopt($curl, CURLOPT_HEADER, 0);
        curl_setopt($curl, CURLOPT_TIMEOUT, 20);
        curl_setopt($curl, CURLOPT_ENCODING, 'gzip');
        curl_setopt($curl, CURLOPT_IPRESOLVE, 1);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
        curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 10);
        curl_setopt($curl, CURLOPT_URL, $API['url']);
        curl_setopt($curl, CURLOPT_COOKIE, $BASE['cookie']);
        curl_setopt($curl, CURLOPT_REFERER, $BASE['referer']);
        curl_setopt($curl, CURLOPT_USERAGENT, $BASE['useragent']);
        $data=curl_exec($curl);
        curl_close($curl);
        return $data;
}


function curlMusic($id, $type = 'list', $br = 320) {
    if ($type === 'list') {
        $API=array(
                    'method' => 'POST',
                    'url'    => 'http://music.163.com/api/linux/forward',
                    'body'   => array(
                        'method' => 'POST',
                        'params' => array(
                            'id' => $id,
                            "n"  => 1000,
                        ),
                        'url' => 'http://music.163.com/api/v3/playlist/detail',
                    ),
                    'encode' => 'netease_AESECB',
                    'format' => 'playlist#tracks',
        );
        $data = json_decode(curl($API))->playlist->tracks;
        foreach($data as $k => $v) {
            $ids[] = $v->id;
        }
        $urlList = json_decode(curlMusic($ids, 'music'))->data;
        foreach ($urlList as $key => $value) {
            $url[] = substr($value->url,5);
        }
        return $url;

    } else {
        if(is_array($id)){
        $API=array(
                    'method' => 'POST',
                    'url'    => 'http://music.163.com/api/linux/forward',
                    'body'   => array(
                        'method' => 'POST',
                        'params' => array(
                            'ids' => $id,
                            'br'  => $br*1000,
                        ),
                        'url' => 'http://music.163.com/api/song/enhance/player/url',
                    ),
                    'encode' => 'netease_AESECB',
                    'decode' => 'netease_url',
                );
            return curl($API);
        } else {
            $API=array(
                    'method' => 'POST',
                    'url'    => 'http://music.163.com/api/linux/forward',
                    'body'   => array(
                        'method' => 'POST',
                        'params' => array(
                            'ids' => array($id),
                            'br'  => $br*1000,
                        ),
                        'url' => 'http://music.163.com/api/song/enhance/player/url',
                    ),
                    'encode' => 'netease_AESECB',
                    'decode' => 'netease_url',
                );
            return substr(json_decode(curl($API))->data[0]->url,5);
        }
        
    
    }
    
}
$id = $this->options->socialmusic;
$url=implode(",", curlMusic($id));
print_r($url);
?>";
                        var musicIco = document.getElementById("musicico");
                        var musicArr = musicSrc.split(",")
                        var musicBtn = document.getElementById("musicBtn");

                        if(!window["musicObj"]){

                        }

                        function IsPC() {
                            var userAgentInfo = navigator.userAgent;
                            var Agents = ["Android", "iPhone","SymbianOS", "Windows Phone","iPad", "iPod"];
                            var flag = true;
                            for (var v = 0; v < Agents.length; v++) {
                                if (userAgentInfo.indexOf(Agents[v]) > 0) {
                                    flag = false;
                                    break;
                                }
                            }
                            return flag;
                        }
                        var i = 0;
                        function playMusic(force){
                            // 双击切换下一首
                            if(i !=  0){
								musicInd = musicArr.indexOf(musicObj.src.split("https:")[1])+1;
								if(musicInd > musicArr.length-1) {
									musicInd = 0;
								}
								
								musicObj.src = musicArr[musicInd];
                                musicObj.play();
                                musicStyle()
                                return;
                            }
                            i++;
                            setTimeout(function(){
                                i = 0
                            },200)

                            if(force == true){
                                musicObj.play();
                                musicStyle()
                                return;
                            }
                            if(musicObj.paused){
                                musicObj.play();
                            }else{
                                musicObj.pause();
                            }
                            musicStyle()
                        }
                        function musicStyle(){
                            if(!musicObj.paused){
                                musicIco.style.animation = "musicplay 5s linear infinite"
                            }else{
                                musicIco.style.animation = ""
                            }
                        }
                        if(!window["musicObj"]){
                            var musicObj = document.createElement("audio");
                            var musicInd = Math.round(Math.random()*(musicArr.length-1));

                            musicObj.src = musicArr[musicInd];
                            musicObj.loop = false;
                            musicObj.style.display = "none"

                            playMusic(true)
                        } 
                        if(musicObj){
							musicObj.addEventListener('ended', function () {  
								musicInd += 1;
								if(musicInd > musicArr.length - 1) {
									musicInd = 0;
								}
								musicObj.src = musicArr[musicInd];
								playMusic(true)
							}, false);
						}

                        musicStyle()
						
                        if(IsPC()){
                            musicBtn.addEventListener("click",function(){
                                playMusic(false)
                            })
                        }else{
                            musicBtn.addEventListener("touchstart",function(){
                                playMusic(false)
                            })
                        }
                    </script>
                    <?php endif; ?>
                    <a id="search-toggle" class="social search" href="javascript:"><i class="iconfont icon-sousuo"></i></a>
                    <form id="search" method="post" action="/" role="search">
                        <input type="text" class="input" name="s" required="true" placeholder="...Search">
                    </form>
                    <div id="wechat">
                        <img src="<?php $this->options->socialwechat(); ?>" />
                    </div>
                </div>
            </nav>

        </header>
    </div>